﻿@using System.Collections
@using CoralNode.Core.Entity.Domains.Site
@using CoralNode.Core.Entity.Enums
@using CoralNode.MvcClient.Helper
@using Coralcode.Base.Utils
@using Coralcode.Utils.Basic
@using System.Linq;
@model CoralNode.Core.Entity.Domains.Site.SiteDomain
@{
    ViewBag.Title = "Edit";
}
@Html.IncludePage("CoralAdmin/seo", "_Left", new { current = "site" })
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_system"></span><span class="t t_c">站点管理&nbsp;&nbsp;/&nbsp;&nbsp;<b
                class=" t_small f_no">编辑站点</b></span>
        </div>
        <div id="main">
            <div class="content_tab extra_normal">
                <div class="tablist extra_normal" data-js="tab">
                    <a href="#">主要信息</a>
                    <a href="#">详细信息</a>
                    @foreach (var group in @ViewBag.SiteExtendGroupList) {
                        <a href="#">@group.Title</a>
                    }
                </div>
            </div>
            <form id="spform" action="/m/seo/editSite/@Model.Id" method="post" enctype="multipart/form-data">
                <div class="pt_3 js_tabcnt">
                    <div class="table_form form_main ">
                        <div class="pl_2 pb_3">
                            <table>
                                <tbody>
                                    <tr>
                                        <th width="60">站点名称<span class="rq">*</span></th>
                                        <td>
                                            @Html.TextBoxFor(m => m.Name, new { @class = "text w_37", @disabled = "disabled" })
                                            @Html.HiddenFor(m => m.Id)
                                            <div class="exp ml_1">4-16个字符，支持英文小写、数字、下划线</div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>域名主机<span class="rq">*</span></th>
                                        <td>@Html.TextBoxFor(m => m.Hosts, new { @class = "text w_37", @disabled = "disabled" })
                                            <div class="exp ml_1">4-16个字符，支持英文小写、数字、下划线</div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th width="60">根目录<span class="rq">*</span></th>
                                        <td>
                                            @Html.TextBoxFor(m => m.Root, new { @class = "text w_37", @disabled = "disabled" })
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>站点主题</th>
                                        <td>
                                            @{
                                                IList<ThemeDomain> themeList = ViewBag.ThemesList;
                                                var theme = themeList.FirstOrDefault(n => n.Code == Model.ThemeCode);
                                            }
                                            @Html.Label(theme.Name)
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>站点语言</th>
                                        <td>
                                            @{
                                                IList<LangDomain> langList = ViewBag.LangList;
                                                var lang = langList.FirstOrDefault(n => n.Code == Model.LangCode);
                                            }
                                            @Html.Label(lang.Title)
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>站点状态</th>
                                        <td>
                                            @EnumUtil.GetEnumDescription(SiteEnums.SiteStatus, Model.Status)
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>字符集</th>
                                        <td>
                                            @EnumUtil.GetEnumDescription(SiteEnums.SiteCharset, Model.Charset)
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="table_form form_main ">

                        <div class="pl_2 pb_3">
                            <table data-js="tabCnt">
                                <tbody>
                                    <tr>
                                        <th width="60">口号</th>
                                        <td>@Html.TextBoxFor(m => m.Slogan, new { @class = "text w_37" })</td>
                                    </tr>
                                    <tr>
                                        <th width="60">作者</th>
                                        <td>@Html.TextBoxFor(m => m.Author, new { @class = "text w_37" })</td>
                                    </tr>
                                    <tr>
                                        <th>版权</th>
                                        <td>@Html.TextBoxFor(m => m.Copyright, new { @class = "text w_37" })</td>
                                    </tr>
                                    <tr>
                                        <th width="60">ICP</th>
                                        <td>@Html.TextBoxFor(m => m.Icp, new { @class = "text w_37" })</td>
                                    </tr>
                                    <tr>
                                        <th>地区</th>
                                        <td>@Html.TextBoxFor(m => m.Area, new { @class = "text w_37" })</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    @foreach (var group in @ViewBag.SiteExtendGroupList) {
                        <div class="table_form form_main ">
                            <div class="pl_2 pb_3">
                                <table>
                                    <tbody>
                                        @foreach (var item in @group.SiteExtendList) {
                                            <tr>
                                                <th width="80px">@item.Title</th>
                                                <td>
                                                    @if (@item.FieldType == SiteEnums.FieldType.TextField) {
                                           
                                                        <input class="text w_37" type="text" name="field.@item.FieldName" validate="@item.Validator" value="@item.Value" />
                                            
                                                        <div class="exp ml_1">@item.Hint</div>
                                                    } else if (@item.FieldType == SiteEnums.FieldType.TextArea) {
                                                        <textarea name="field.@item.FieldName" validate="@item.Validator" class="h_8 w_37">@item.Value</textarea>
                                                        <div class="exp ml_1">@item.Hint</div>
                                                    } else if (@item.FieldType == SiteEnums.FieldType.PasswordField) {
                                                        <input name="field.@item.FieldName" class="text w_37" type="password" validate="@item.Validator" value="@item.Value"/>
                                                        <div class="exp ml_1">@item.Hint</div>
                                       
                                                    } else if (@item.FieldType == SiteEnums.FieldType.FileField) {
                                                        <div class="coralfile" module="@Model.ThemeCode/@item.FieldName"  name="field.@item.FieldName"  value="@item.Value">
                                                        </div>
                                                        <div class="exp ml_1">@item.Hint</div>
                                                    } else if (@item.FieldType == SiteEnums.FieldType.ImageField) {
                                                        <input type="hidden" validate="@item.Validator" name="field.@item.FieldName" value="@item.Value"/>
                                                        <ul class="list_img" href="/m/common/upload" data-js="listimg">
                                                            <li class="btn li_add js_openuploader" data-meta="{data:'{module:\'@Model.Name/@item.FieldName\'}',multi:false,method:'add',type:'image'}">
                                                                <span class="ico ico_upload_image"></span>
                                                            </li>
                                                        </ul>
                                                        <div class="exp ml_1">@item.Hint</div>
                                                    } else if (@item.FieldType == SiteEnums.FieldType.MultiImage) {
                                                        <input type="hidden" validate="@item.Validator" name="field.@item.FieldName" value="@item.Value"/>
                                                        <ul class="list_img" href="/m/common/upload" data-js="listimg">
                                                            <li class="btn li_add js_openuploader" data-meta="{data:'{module:\'@Model.Name/@item.FieldName\'}',multi:true,method:'add',type:'image'}">
                                                                <span class="ico ico_upload_image"></span>
                                                            </li>
                                                        </ul>
                                                        <div class="exp ml_1">@item.Hint</div>
                                                    } else {
                                                        <textarea name="field.@item.FieldName" id="@item.FieldName" >@item.Value</textarea>
                                                        <script type="text/javascript">
                                                            UE.getEditor('@item.FieldName')
                                                        </script>
                                                        <div class="exp ml_1">@item.Hint</div>
                                                    }
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    }
                </div>
                <div class="submitbox p_2 extra_normal">
                    <input type="submit" class="btn_1" value="提    交" />
                </div>
            </form>
        </div>
    </div>
</div>
@if (Model.Status == SiteEnums.SiteStatus.Management) {
    <script type="text/javascript">
        $(document).ready(function () {
            $('.nav_main').find("li").eq(2).removeClass().end().eq(4).addClass("current");
        })
    </script>
}
